package org.stwy.bills;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.stwy.lease.contract.ContractAssetEntity;
import org.stwy.lease.contract.ContractAssetService;

import com.rap.common.persistence.IBaseDAO;
import com.rap.common.exception.ServiceException;
import com.rap.common.service.BaseServiceImpl;

/**
 * 收费管理 服务类
 */
/**
*版权信息 (c) RAP 保留所有权利.
*@author 4028b22741f912710141f91290150000
*@Team RAP Team
*@Date 2015-6-25 21:55:40
*<p></p>
*
*@参与人：4028b22741f912710141f91290150000
*/
 
@Service
@Transactional(rollbackFor={Exception.class})
public class BillsService extends BaseServiceImpl<BillsEntity, String> {

	@Autowired
	private BillsDAO dao;
	
	@Autowired
	private ContractAssetService contractAssetService;

	
	@Override
	protected IBaseDAO getDAO() {
		return dao;
	}

	public String[] getPropertyByContractId(String contractId) throws ServiceException  {
		List<ContractAssetEntity> list = contractAssetService.findByContractId(contractId);
		if(list==null||list.size()==0){
			throw new ServiceException("提示：所选合同不存在承租资产");
		}
		String[] info = new String[3];
		info[0]=list.get(0).getAsset().getProperty().getTheName();
		String asset = "";
		for(ContractAssetEntity entity :list){
			asset=asset+"\\"+entity.getAsset().getTheName();
		}
		asset = asset.substring(1);
		info[1]=asset;
		info[2] = list.get(0).getContract().getCustom().getTheName();
		return info;
	}
	
	/**
	 * 自定义service方法，注意抛出异常
	 * @throws ServiceException
	 */
	/*
	public void methdA() throws ServiceException {
		try {
			//Do some things
		} catch (Exception e) {
			throw new ServiceException(e.getMessage());
		}
	}
	*/
}
